#include <cstdio>

const int Limit_Size = 20000;

int c1[ Limit_Size ], c2[ Limit_Size ];
int total, num[ 3 ];
int coin[ 3 ];

void work( )
{
    int i, j, k;
    total = num[ 0 ] + num[ 1 ] * 2 + num[ 2 ] * 5;
    for ( i = 0; i <= total + 1; i++ )
        c1[ i ] = c2[ i ] = 0;
    for ( i = 0; i <= num[ 0 ]; i++ )
        c1[ i ] = 1;
    for ( i = 1; i <= 2; i++ )
    {
        for ( j = 0; j <= total; j++ )
            for ( k = 0; k <= num[ i ] * coin[ i ] && j + k <= total; k += coin[ i ] )
                c2[ j + k ] += c1[ j ];
        for ( j = 0; j <= total; j++ )
        {
            c1[ j ] = c2[ j ];
            c2[ j ] = 0;
        }
    }
}

void print( )
{
    int i;
    for ( i = 1; i <= 20000; i++ )
        if ( !c1[ i ] )
        {
            printf("%d\n", i);
            break;
        }
}

int main( )
{
    coin[ 0 ] = 1; coin[ 1 ] = 2; coin[ 2 ] = 5;
    while ( scanf("%d%d%d", &num[ 0 ], &num[ 1 ], &num[ 2 ]) != EOF )
    {
        if ( num[ 0 ] == 0 && num[ 1 ] == 0 && num[ 2 ] == 0 )
            break;
        work( );
        print( );
    }
    return 0;
}
